package org.budo.selenium.phantomjs;

import org.budo.support.java.net.util.JavaNetUtil;
import org.budo.support.lang.util.SystemUtil;

import lombok.Getter;

/**
 * @author lmw
 */
@Getter
public enum PhantomjsSystem {
    Windows("http://taojinyun.file.itaojin.cn/2021-04/481c322a6d0f457ba311c8adf3214e8c", 18587648L),

    Mac("http://taojinyun.file.itaojin.cn/2021-04/93b4affa27c547c28132f1312a1e2a24", 45020592L),

    Linux32("http://taojinyun.file.itaojin.cn/2021-04/f6eb5d59bf5f41bf8e17db77e5f4ef58.phantomjs", 70678128L),

    Linux64("http://taojinyun.file.itaojin.cn/2021-04/77dff4c42aec4f92b6a7a6031586b338.phantomjs", 67932064L);

    PhantomjsSystem(String url, Long size) {
        this.url = url;
        this.size = size;
    }

    private String url;

    private Long size;

    public static PhantomjsSystem now() {
        if (SystemUtil.isWindows()) {
            return PhantomjsSystem.Windows;
        }

        if (SystemUtil.isLinux32()) {
            return PhantomjsSystem.Linux32;
        }

        if (SystemUtil.isLinux64()) {
            return PhantomjsSystem.Linux64;
        }

        if (SystemUtil.isMac()) {
            return PhantomjsSystem.Mac;
        }

        throw new RuntimeException("#47 unknown os " + SystemUtil.getOsName() + ", ips=" + JavaNetUtil.getIpAddresses());
    }
}